package scau.jump.securitytrace.util;

import java.util.List;
import java.util.Vector;

import com.securitytrace.model.User;


public class UserConvertToVector extends ConvertAdapter<User> {

	public  Vector<?> convertToVector(List<User> users) {
		if(users == null || users.size()<1) {
			return null;
		}
		Vector<Vector<?>> vectors = new Vector<Vector<?>>();
		for(User user : users) {
			if(convertToVector(user)== null) {
				return null;
			}
			vectors.add(convertToVector(user));
		}
		return vectors;
	}

	public Vector<?> convertToVector(User user) {
		if(user == null) {
			return null;
		}
		Vector<String> vector = new Vector<String>();
		String account = user.getAccount();
		String password = user.getPassword();
		String role	= user.getRole().getName();
		String address = user.getAddress().getAddressName();
		vector.add(account);
		vector.add(password);
		vector.add(role);
		vector.add(address);
		return vector;
	}

}
